<?php
$connect = connexion ( SQLHOST, SQLUSER, SQLPASS, SQLDB );
$req = 'SELECT DISTINCT commande.id, commande.libelle, commande.dateD, commande.dateF, statut.libelle AS statut, user.nom AS nomPersonne, type_commande.libelle as typeCommande
FROM type_commande, commande, user, statut
WHERE commande.nomPersonne = user.id
AND commande.statut = statut.id
AND commande.typeCommande = type_commande.id
AND commande.libelle = "'. $_POST ['libelle'].'"';

$result = extraire ( $connect, $req );
$row = mysql_fetch_array ( $result );
$num=@mysql_numrows($result);

?>


  <script>
            jQuery(function($) {
                var items = $("#content tbody tr");

                var numItems = items.length;
                var perPage = 10;

                // only show the first 2 (or "first per_page") items initially
                items.slice(perPage).hide();

                // now setup pagination
                $("#pagination").pagination({
                    items: numItems,
                    itemsOnPage: perPage,
                    cssStyle: "light-theme",
                    onPageClick: function(pageNumber) { // this is where the magic happens
                        // someone changed page, lets hide/show trs appropriately
                        var showFrom = perPage * (pageNumber - 1);
                        var showTo = showFrom + perPage;

                        items.hide().slice(showFrom, showTo).show();
                    }
                });
            });
        </script>
        
        

<center>

<p><img src="images/add.png" height="22" width="22" /><a href="index.php?module=nouvelleCommande">Cr&eacute;er une nouvelle commande</a> &nbsp;&nbsp;
<br/><img src="images/filter.png" height="22" width="22" /><a href="index.php?module=recupererFiltre">Appliquer un autre filtre</a> &nbsp;&nbsp;
<br/><img src="images/delete.png" height="22" width="22" /><a href="index.php?module=consultation">Supprimer le filtre</a></p>
<table  class="table" id="content">
<thead>

<tr bgcolor = "#A4A4A4">
	<td>
		<font face="Arial, Helvetica, sans-serif"><b>Nom</b></font>
	</td>
	<td>
		<font face="Arial, Helvetica, sans-serif"><b>Libelle</b></font>
	</td>
	<td>
		<font face="Arial, Helvetica, sans-serif"><b>Date Commande</b></font>
	</td>
	<td>
		<font face="Arial, Helvetica, sans-serif"><b>Date Livraison</b></font>
	</td>
	<td>
		<font face="Arial, Helvetica, sans-serif"><strong>Status</strong></font>
	</td>
	<td>
		<font face="Arial, Helvetica, sans-serif"><strong>Type</strong></font>
	</td>
	<td>
		<font face="Arial, Helvetica, sans-serif"><strong>Modif.</strong></font>
	</td>
</tr>
</thead>
<tbody>
<?php
$i=0;while ($i < $num) {
$f0=mysql_result($result,$i,"id");
$f1=mysql_result($result,$i,"nomPersonne");
$f2=mysql_result($result,$i,"libelle");
$f3=mysql_result($result,$i,"dateD");
$f4=mysql_result($result,$i,"dateF");
$f5=mysql_result($result,$i,"statut");
$f6=mysql_result($result,$i,"typeCommande");
?>
<tr>
	<td>
		<font face="Arial, Helvetica, sans-serif"><?php echo $f1; ?></font>
	</td>
	<td>
		<font face="Arial, Helvetica, sans-serif"><?php echo $f2; ?></font>
	</td>
	<td>
		<font face="Arial, Helvetica, sans-serif"><?php echo $f3; ?></font>
	</td>
	<td>
		<font face="Arial, Helvetica, sans-serif"><?php echo $f4; ?></font>
	</td>
	<td>
		<font face="Arial, Helvetica, sans-serif"><?php echo $f5; ?></font>
	</td>
	<td>
		<font face="Arial, Helvetica, sans-serif"><?php echo $f6; ?></font>
	</td>
	<td>
		<form method="post" action="index.php?module=modifierCommande">
		<input type="hidden" id="id" name="id"  value="<?php echo $f0; ?>" >
		<input type="hidden" id="libelle" name="libelle"  value="<?php echo $f2; ?>" >
		<input type="hidden" id="dated" name="dated"  value="<?php echo $f3; ?>" >
		<input type="hidden" id="datef" name="datef"   value="<?php echo $f4; ?>" >
		<input type="hidden" id="statut" name="statut"   value="<?php echo $f5; ?>" >
		<input type="hidden" id="npersonne" name="npersonne" value="'.$_SESSION['login'].'" >
		<input type="hidden" id="tcommande" name="type"   value="<?php echo $f6; ?>" >
		<center><button class="button btn btn-warning btn-large" id="button" value="Modifier" type="submit" name="consultation">Modifier</button></center>
		</form>
	</td>
</tr>
</center>
<?php
$i++;}
?>
</tbody>
</table>
<br/>
<div  id="pagination"></div>